home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / phxassmode.fpl < prev    next >
Text File  |  1996-04-02  |  4KB  |  143 lines

  1. // $Id: PhxAssMode.FPL 1.5 1996/04/02 18:31:39 jskov Exp $
  2. // $VER: PhxAssMode.FPL 1.0 (19.10.95) © Jesper Skov
  3.  
  4. int parseLine = 0;
  5.  
  6. int entryID;
  7.  
  8. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» phxAssemble() ««
  9. export void phxAssemble()
  10. {
  11.   int parent = GetBufferID();
  12.   string path = ReadInfo("file_path");
  13.   string me;
  14.   int stat;
  15.  
  16.   if(!ReadInfo("filehandler")){
  17.     SetInfo(-2,"filehandler",1);
  18.     Delay(50);                                // wait 2 secs
  19.   }
  20.     
  21.   me = "\""+ReadInfo("disk_name")+":_phx assemble_\"";
  22.  
  23.   if (!strlen(path))
  24.     path = ReadInfo("directory");
  25.  
  26.   if(!(entryID = GetEntryID("_phx assemble_"))){
  27.     entryID = New();
  28.     parent = CurrentBuffer(entryID);
  29.     Rename("_phx assemble_");
  30.     CurrentBuffer(parent);
  31.  
  32.     Visible(0);
  33.     Activate(entryID,1);
  34.     ResizeView(ReadInfo("view_lines")+ReadInfo("view_lines",entryID)-ReadInfo("phxass_output_height"),parent);
  35.  
  36.     Visible(1);
  37.     RedrawScreen();
  38.   }
  39.  
  40.   Save();
  41.  
  42.   CurrentBuffer(entryID);
  43.   GotoLine(1);
  44.   CurrentBuffer(parent);
  45.  
  46.   if(Check(path+"Makefile")){
  47.     SaveString("T:phxAssemble","echo >"+me+" cd "+path+"\nmake >>"+me);
  48.     stat = System("execute t:phxAssemble");
  49.   } else 
  50.     stat = System(ReadInfo("phxass_assembler")+" >"+me+" FROM "+ReadInfo("full_file_name")+" "+ReadInfo("phxass_options"));
  51.  
  52.   if(stat)
  53.     ReturnStatus("There were errors! Press C-c ' to find them!");
  54.   else
  55.     ReturnStatus("Successful operation!");
  56. }
  57.  
  58. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» phxAssParseError() ««
  59. export void phxAssParseError()
  60. {
  61.   int parent = CurrentBuffer(entryID);
  62.  
  63.   if(Search("(= line ","=f+")){
  64.     if(ReadInfo("line")==1){
  65.       ReturnStatus("No errors found!");
  66.       CurrentBuffer(parent);
  67.       return;
  68.     } else {
  69.       GotoLine(1);
  70.       CurrentBuffer(parent);
  71.       ReturnStatus("No more errors found!");
  72.       return;
  73.     }    
  74.   } else {
  75.     int errLine;
  76.     string errFile, errText;
  77.  
  78.     CursorRight(8);
  79.     errLine = atoi(GetWord());
  80.     CursorRightWord(2);
  81.     errFile = substr(GetLine(),ReadInfo("byte_position"),ReadInfo("line_length")-ReadInfo("byte_position")-2);
  82.     GotoLine(ReadInfo("line")-1,0);
  83.     CursorRightWord();
  84.     errText = substr(GetLine(),ReadInfo("byte_position"),ReadInfo("line_length")-ReadInfo("byte_position")-1);
  85.     CursorDown(2);
  86.     InverseLine(ReadInfo("cursor_y")-1);
  87.     InverseLine(ReadInfo("cursor_y")-2);
  88.     InverseLine(ReadInfo("cursor_y")-3);
  89.  
  90.     if(stricmp(Stcgfn(errFile),ReadInfo("file_name",parent))){
  91.       int other = GetBufferID(Stcgfn(errFile));
  92.  
  93.       if (!other){
  94.         other = New();
  95.         CurrentBuffer(other);
  96.         Load(errFile);
  97.       }
  98.       CurrentBuffer(other);
  99.       Activate(other, 0, parent);            // replace parent with erroneous
  100.     } else
  101.       CurrentBuffer(parent);
  102.  
  103.     GotoLine(errLine);
  104.     ReturnStatus(errText);
  105.   }
  106. }
  107.  
  108. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» phxAssPrefs() ««
  109. export void PhxAssModePrefs()
  110. {
  111.   PromptInfo(-1,"PhxAssMode Preferences",-1,-1,
  112.    "phxass_assembler",
  113.    "phxass_output_height",
  114.    "phxass_options"
  115.   );
  116. }
  117.  
  118. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» key bindings ««
  119. AssignKey("phxAssemble();","control c control c", "phxass_mode");
  120. AssignKey("phxAssParseError();","control c '0x2a'","phxass_mode");
  121.  
  122. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» PhxAssMode settings ««
  123.  
  124. ConstructInfo("phxass_assembler", "","", "GSHW","", 0,0,"phxass");
  125. ConstructInfo("phxass_options", "","", "GSHW","", 0,0,"");
  126. ConstructInfo("phxass_output_height","","","GIHW","",0,100,14);
  127.  
  128.  
  129. ConstructInfo("phxass_mode", "","", "LBH","", 0,0,0);
  130. ConstructInfo("phxass_mode_ext", "","", "GSHW","", 0,0,"*s*i*asm*");
  131. ConstructInfo("phxass_mode_exe", "","", "GSHW","", 0,0,"AsmModeInit();");
  132.  
  133. AddMode(1, "phxass_mode", "phxass_mode_ext", "phxass_mode_exe");
  134.  
  135. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» PhxAss menu ««
  136. MenuAdd("i", "PhxAss", "", "", ReadInfo("Program_Menu"), -1);
  137.  MenuAdd("s", "Assemble", "phxAssemble();","", ReadInfo("Program_Menu"), -1);
  138.  MenuAdd("s", "---","","",ReadInfo("Program_Menu"), -1);
  139.  MenuAdd("s", "Next error", "phxAssParseError();","",ReadInfo("Program_Menu"), -1);
  140.  
  141. MenuAdd("s", "PhxAss...", "PhxAssModePrefs();", "", ReadInfo("menu_program_title"),ReadInfo("menu_program_item"),-1);
  142. MenuBuild();
  143.